package com.baijia.services;

import java.io.Serializable;
import java.util.List;

import com.baijia.authentication.principal.Service;
/**
 * @title RegisteredService
 * @desc 注册在passport的系统
 * @author caoliang
 * @date 2015年12月5日
 * @version 1.0
 */
public interface RegisteredService extends Cloneable, Serializable {    
    /**
     * Is this application currently allowed to use CAS?
     * 
     * @return true if it can use CAS, false otherwise.
     */
    boolean isEnabled();

    /**
     * Sets whether we should bother to read the attribute list or not.
     * 
     * @return true if we should read it, false otherwise.
     */
    boolean isIgnoreAttributes();

    /**
     * Returns the list of allowed attributes.
     * 
     * @return the list of attributes
     */
    List<String> getAllowedAttributes();

    /**
     * The unique identifier for this service.
     * 
     * @return the unique identifier for this service.
     */
    String getServiceId();

    /**
     * The numeric identifier for this service.
     * 
     * @return the numeric identifier for this service.
     */
    int getId();

    /**
     * Returns the name of the service.
     * 
     * @return the name of the service.
     */
    String getName();

    /**
     * Returns a short theme name. Services do not need to have unique theme
     * names.
     * 
     * @return the theme name associated with this service.
     */
    String getTheme();

    /**
     * Does this application participate in the SSO session?
     * 
     * @return true if it does, false otherwise.
     */
    boolean isSsoEnabled();

    /**
     * Returns the description of the service.
     * 
     * @return the description of the service.
     */
    String getDescription();
   
    /**
     * Gets the relative evaluation order of this service when determining
     * matches.
     * @return Evaluation order relative to other registered services.
     * Services with lower values will be evaluated for a match before others.
     */
    int getEvaluationOrder();

    /**
     * Sets the relative evaluation order of this service when determining
     * matches.
     */
    void setEvaluationOrder(final int evaluationOrder);
    
    /**
     * Get the name of the attribute this service prefers to consume as username.
     * 
     * @return Either of the following values:
     * <ul>
     *  <li><code>String</code> representing the name of the attribute to consume as username</li>
     *  <li><code>null</code> indicating the default username</li>
     * </ul>
     */
    public String getUsernameAttribute();
    
    /**
     * Returns whether the service matches the registered service.
     * <p>Note, as of 3.1.2, matches are case insensitive.
     * 
     * @param service the service to match.
     * @return true if they match, false otherwise.
     */
    boolean matches(final Service service);
    
    Object clone() throws CloneNotSupportedException;
    
    public List<String> getAllowDomains();
    
    public String getLoginAddr();
    
    public String getLoginSuccessAddr();
}
